package com.shop.bank.service.impl;

import com.shop.bank.dao.AccountMapper;
import com.shop.bank.pojo.Account;
import com.shop.bank.pojo.Transactionrecord;
import com.shop.bank.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public int loginn(Account account) {
        return accountMapper.loginn(account);
    }

    @Override
    public BigDecimal moneyselect(String cardNo) {
        return accountMapper.moneyselect(cardNo);
    }

    @Override
    @Transactional
    public int zz(Map map) {
        int count=0;
        int cardNo = accountMapper.selectId((String) map.get("cardNo"));

        if(cardNo>0)
        {
            if(accountMapper.zzjian(map)>0)
            {
                count=1;
            }
            if(accountMapper.zzjia(map)>0)
            {
                count=1;
            }
        }else {
            count=2;
        }

        return count ;
    }

    @Override
    public int updatepwd(Map map) {
        return accountMapper.updatepwd(map);
    }

    @Override
    public List<Transactionrecord> listall(String cardNo) {
        return accountMapper.listall(cardNo);
    }
}
